#ifndef _TLS_CONNECTION_H
#define _TLS_CONNECTION_H

#include <linux/inet.h>
#include <linux/socket.h>
#include <net/sock.h>
#include <crypto/curve25519.h>
#define port_num 9999
#define PACKET unsigned char

typedef struct ssl_connection {
    PACKET peer_pubkey[CURVE25519_KEY_SIZE];
    PACKET prikey[CURVE25519_KEY_SIZE];
    PACKET pubkey[CURVE25519_KEY_SIZE];
    PACKET pms[CURVE25519_KEY_SIZE];
    int server; 
    int hand_state;
    int pkt_size;
    char cert_type;
} SSL_CONNECTION;

typedef struct tcp_connection {
    struct socket *sock;
    PACKET *buf;
    SSL_CONNECTION *ssl;
} TCP_CONNECTION;

typedef struct __attribute__((__packed__)) record_layer_st {
    unsigned char type;
    unsigned short version;
    unsigned short length;
} RECORD_LAYER;

typedef struct __attribute__((__packed__)) sub_record_layer_st {
    unsigned short type;
    unsigned short length;
    unsigned short version;
    unsigned char  random[32];
} SUB_RECORD_LAYER;

typedef struct __attribute__((__packed__)) cert_sub_record_layer_st {
    unsigned short type;
    unsigned short length;
    unsigned short cert_length;
} CERT_SUB_RECORD_LAYER;

typedef struct __attribute__((__packed__)) key_share_layer_st {
    unsigned short group_id;
    unsigned short length;
    unsigned char  keyshare[32];
} KEY_SHARE_LAYER;

int client_init_connection(TCP_CONNECTION *conn);
int server_init_listen(TCP_CONNECTION *conn);

#endif


